<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE CPP, MagicHash, UnboxedTuples, NoImplicitPrelude #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# OPTIONS_GHC -O2 #-}</span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# OPTIONS_HADDOCK not-home #-}</span><span>
</span><span id="line-5"></span><span>
</span><span id="line-6"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Module      :  GHC.Float.ConversionUtils</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Copyright   :  (c) Daniel Fischer 2010</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- License     :  see libraries/base/LICENSE</span><span>
</span><span id="line-11"></span><span class="hs-comment">--</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Maintainer  :  cvs-ghc@haskell.org</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Stability   :  internal</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Portability :  non-portable (GHC Extensions)</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Utilities for conversion between Double/Float and Rational</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span class="hs-cpp">

#include &quot;MachDeps.h&quot;
</span><span>
</span><span id="line-22"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Float.ConversionUtils</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Float.ConversionUtils.html#elimZerosInteger"><span class="hs-identifier">elimZerosInteger</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Float.ConversionUtils.html#elimZerosInt%23"><span class="hs-identifier">elimZerosInt#</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-23"></span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#"><span class="hs-identifier">GHC.Num.Integer</span></a></span><span class="hs-cpp">
#if WORD_SIZE_IN_BITS &lt; 64
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">GHC.IntWord64</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-30"></span><span class="hs-keyword">default</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-cpp">

#if WORD_SIZE_IN_BITS &lt; 64
</span><span class="hs-cpp">
#define TO64    integerToInt64#
</span><span>
</span><span id="line-36"></span><span class="hs-identifier">toByte64#</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Int64#</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int#</span><span>
</span><span id="line-37"></span><span class="hs-identifier">toByte64#</span><span> </span><span class="hs-identifier">i</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">word2Int#</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">and#</span><span> </span><span class="hs-number">255##</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">int2Word#</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">int64ToInt#</span><span> </span><span class="hs-identifier">i</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span class="hs-comment">-- Double mantissae have 53 bits, too much for Int#</span><span>
</span><span id="line-40"></span><span class="hs-identifier">elim64#</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Int64#</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int#</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="hs-identifier">Integer</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">Int#</span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-41"></span><span class="hs-identifier">elim64#</span><span> </span><span class="hs-identifier">n</span><span> </span><span class="hs-identifier">e</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-42"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">zeroCount</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">toByte64#</span><span> </span><span class="hs-identifier">n</span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-43"></span><span>      </span><span class="hs-identifier">t</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">isTrue#</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">e</span><span> </span><span class="hs-operator">&lt;=#</span><span> </span><span class="hs-identifier">t</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="hs-identifier">integerFromInt64#</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">uncheckedIShiftRA64#</span><span> </span><span class="hs-identifier">n</span><span> </span><span class="hs-identifier">e</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-number">0#</span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-44"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">isTrue#</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">t</span><span> </span><span class="hs-operator">&lt;#</span><span> </span><span class="hs-number">8#</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="hs-identifier">integerFromInt64#</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">uncheckedIShiftRA64#</span><span> </span><span class="hs-identifier">n</span><span> </span><span class="hs-identifier">t</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">e</span><span> </span><span class="hs-operator">-#</span><span> </span><span class="hs-identifier">t</span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-45"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">otherwise</span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">elim64#</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">uncheckedIShiftRA64#</span><span> </span><span class="hs-identifier">n</span><span> </span><span class="hs-number">8#</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">e</span><span> </span><span class="hs-operator">-#</span><span> </span><span class="hs-number">8#</span><span class="hs-special">)</span><span class="hs-cpp">

#else
</span><span class="hs-cpp">
#define TO64    integerToInt#
</span><span>
</span><span id="line-51"></span><span class="hs-comment">-- Double mantissae fit it Int#</span><span>
</span><span id="line-52"></span><span class="annot"><a href="GHC.Float.ConversionUtils.html#elim64%23"><span class="hs-identifier hs-type">elim64#</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Int%23"><span class="hs-identifier hs-type">Int#</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Int%23"><span class="hs-identifier hs-type">Int#</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#Integer"><span class="hs-identifier hs-type">Integer</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Int%23"><span class="hs-identifier hs-type">Int#</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-53"></span><span id="elim64%23"><span class="annot"><span class="annottext">elim64# :: Int# -&gt; Int# -&gt; (# Integer, Int# #)
</span><a href="GHC.Float.ConversionUtils.html#elim64%23"><span class="hs-identifier hs-var hs-var">elim64#</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; (# Integer, Int# #)
</span><a href="GHC.Float.ConversionUtils.html#elimZerosInt%23"><span class="hs-identifier hs-var">elimZerosInt#</span></a></span><span class="hs-cpp">

#endif
</span><span>
</span><span id="line-57"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Float.ConversionUtils.html#elimZerosInteger"><span class="hs-pragma hs-type">elimZerosInteger</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-58"></span><span class="annot"><a href="GHC.Float.ConversionUtils.html#elimZerosInteger"><span class="hs-identifier hs-type">elimZerosInteger</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#Integer"><span class="hs-identifier hs-type">Integer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Int%23"><span class="hs-identifier hs-type">Int#</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#Integer"><span class="hs-identifier hs-type">Integer</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Int%23"><span class="hs-identifier hs-type">Int#</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-59"></span><span id="elimZerosInteger"><span class="annot"><span class="annottext">elimZerosInteger :: Integer -&gt; Int# -&gt; (# Integer, Int# #)
</span><a href="GHC.Float.ConversionUtils.html#elimZerosInteger"><span class="hs-identifier hs-var hs-var">elimZerosInteger</span></a></span></span><span> </span><span id="local-6989586621679500419"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679500419"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679500418"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500418"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; (# Integer, Int# #)
</span><a href="GHC.Float.ConversionUtils.html#elim64%23"><span class="hs-identifier hs-var">elim64#</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-identifier">TO64</span><span> </span><span class="hs-identifier">m</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">e</span><span>
</span><span id="line-60"></span><span>
</span><span id="line-61"></span><span class="annot"><a href="GHC.Float.ConversionUtils.html#elimZerosInt%23"><span class="hs-identifier hs-type">elimZerosInt#</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Int%23"><span class="hs-identifier hs-type">Int#</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Int%23"><span class="hs-identifier hs-type">Int#</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><a href="../../ghc-bignum/src/GHC.Num.Integer.html#Integer"><span class="hs-identifier hs-type">Integer</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Int%23"><span class="hs-identifier hs-type">Int#</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-62"></span><span id="elimZerosInt%23"><span class="annot"><span class="annottext">elimZerosInt# :: Int# -&gt; Int# -&gt; (# Integer, Int# #)
</span><a href="GHC.Float.ConversionUtils.html#elimZerosInt%23"><span class="hs-identifier hs-var hs-var">elimZerosInt#</span></a></span></span><span> </span><span id="local-6989586621679500417"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500417"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621679500416"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500416"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-63"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int#
</span><a href="GHC.Float.ConversionUtils.html#zeroCount"><span class="hs-identifier hs-var">zeroCount</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int# -&gt; Int#
</span><a href="GHC.Float.ConversionUtils.html#toByte%23"><span class="hs-identifier hs-var">toByte#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500417"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-64"></span><span>      </span><span id="local-6989586621679500413"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500413"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#isTrue%23"><span class="hs-identifier hs-var">isTrue#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500416"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#%3C%3D%23"><span class="hs-operator hs-var">&lt;=#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500413"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Integer
</span><a href="../../ghc-bignum/src/GHC.Num.Integer.html#IS"><span class="hs-identifier hs-var">IS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#uncheckedIShiftRA%23"><span class="hs-identifier hs-var">uncheckedIShiftRA#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500417"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500416"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">0#</span></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-65"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#isTrue%23"><span class="hs-identifier hs-var">isTrue#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500413"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#%3C%23"><span class="hs-operator hs-var">&lt;#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">8#</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Integer
</span><a href="../../ghc-bignum/src/GHC.Num.Integer.html#IS"><span class="hs-identifier hs-var">IS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#uncheckedIShiftRA%23"><span class="hs-identifier hs-var">uncheckedIShiftRA#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500417"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500413"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500416"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#-%23"><span class="hs-operator hs-var">-#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500413"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-66"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; (# Integer, Int# #)
</span><a href="GHC.Float.ConversionUtils.html#elimZerosInt%23"><span class="hs-identifier hs-var">elimZerosInt#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#uncheckedIShiftRA%23"><span class="hs-identifier hs-var">uncheckedIShiftRA#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500417"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">8#</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500416"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#-%23"><span class="hs-operator hs-var">-#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">8#</span></span><span class="hs-special">)</span><span>
</span><span id="line-67"></span><span>
</span><span id="line-68"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Float.ConversionUtils.html#zeroCount"><span class="hs-pragma hs-type">zeroCount</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-69"></span><span class="annot"><a href="GHC.Float.ConversionUtils.html#zeroCount"><span class="hs-identifier hs-type">zeroCount</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Int%23"><span class="hs-identifier hs-type">Int#</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Int%23"><span class="hs-identifier hs-type">Int#</span></a></span><span>
</span><span id="line-70"></span><span id="zeroCount"><span class="annot"><span class="annottext">zeroCount :: Int# -&gt; Int#
</span><a href="GHC.Float.ConversionUtils.html#zeroCount"><span class="hs-identifier hs-var hs-var">zeroCount</span></a></span></span><span> </span><span id="local-6989586621679500411"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500411"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-71"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">BA
</span><a href="GHC.Float.ConversionUtils.html#zeroCountArr"><span class="hs-identifier hs-var">zeroCountArr</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-72"></span><span>      </span><span class="annot"><a href="GHC.Float.ConversionUtils.html#BA"><span class="hs-identifier hs-type">BA</span></a></span><span> </span><span id="local-6989586621679500408"><span class="annot"><span class="annottext">ByteArray#
</span><a href="#local-6989586621679500408"><span class="hs-identifier hs-var">ba</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ByteArray# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#indexInt8Array%23"><span class="hs-identifier hs-var">indexInt8Array#</span></a></span><span> </span><span class="annot"><span class="annottext">ByteArray#
</span><a href="#local-6989586621679500408"><span class="hs-identifier hs-var">ba</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500411"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-73"></span><span>
</span><span id="line-74"></span><span class="annot"><a href="GHC.Float.ConversionUtils.html#toByte%23"><span class="hs-identifier hs-type">toByte#</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Int%23"><span class="hs-identifier hs-type">Int#</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Int%23"><span class="hs-identifier hs-type">Int#</span></a></span><span>
</span><span id="line-75"></span><span id="toByte%23"><span class="annot"><span class="annottext">toByte# :: Int# -&gt; Int#
</span><a href="GHC.Float.ConversionUtils.html#toByte%23"><span class="hs-identifier hs-var hs-var">toByte#</span></a></span></span><span> </span><span id="local-6989586621679500407"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500407"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#word2Int%23"><span class="hs-identifier hs-var">word2Int#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word# -&gt; Word# -&gt; Word#
</span><a href="../../ghc-prim/src/GHC.Prim.html#and%23"><span class="hs-identifier hs-var">and#</span></a></span><span> </span><span class="annot"><span class="annottext">Word#
</span><span class="hs-number">255##</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int# -&gt; Word#
</span><a href="../../ghc-prim/src/GHC.Prim.html#int2Word%23"><span class="hs-identifier hs-var">int2Word#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500407"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-76"></span><span>
</span><span id="line-77"></span><span>
</span><span id="line-78"></span><span class="hs-keyword">data</span><span> </span><span id="BA"><span class="annot"><a href="GHC.Float.ConversionUtils.html#BA"><span class="hs-identifier hs-var">BA</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="BA"><span class="annot"><a href="GHC.Float.ConversionUtils.html#BA"><span class="hs-identifier hs-var">BA</span></a></span></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#ByteArray%23"><span class="hs-identifier hs-type">ByteArray#</span></a></span><span>
</span><span id="line-79"></span><span>
</span><span id="line-80"></span><span class="hs-comment">-- Number of trailing zero bits in a byte</span><span>
</span><span id="line-81"></span><span class="annot"><a href="GHC.Float.ConversionUtils.html#zeroCountArr"><span class="hs-identifier hs-type">zeroCountArr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Float.ConversionUtils.html#BA"><span class="hs-identifier hs-type">BA</span></a></span><span>
</span><span id="line-82"></span><span id="zeroCountArr"><span class="annot"><span class="annottext">zeroCountArr :: BA
</span><a href="GHC.Float.ConversionUtils.html#zeroCountArr"><span class="hs-identifier hs-var hs-var">zeroCountArr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-83"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679500406"><span class="annot"><span class="annottext">mkArr :: State# d -&gt; ByteArray#
</span><a href="#local-6989586621679500406"><span class="hs-identifier hs-var hs-var">mkArr</span></a></span></span><span> </span><span id="local-6989586621679500405"><span class="annot"><span class="annottext">State# d
</span><a href="#local-6989586621679500405"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-84"></span><span>          </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; State# d -&gt; (# State# d, MutableByteArray# d #)
forall d. Int# -&gt; State# d -&gt; (# State# d, MutableByteArray# d #)
</span><a href="../../ghc-prim/src/GHC.Prim.html#newByteArray%23"><span class="hs-identifier hs-var">newByteArray#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">256#</span></span><span> </span><span class="annot"><span class="annottext">State# d
</span><a href="#local-6989586621679500405"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-85"></span><span>            </span><span class="hs-special">(#</span><span> </span><span id="local-6989586621679500404"><span class="annot"><span class="annottext">State# d
</span><a href="#local-6989586621679500404"><span class="hs-identifier hs-var">s1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679500403"><span class="annot"><span class="annottext">MutableByteArray# d
</span><a href="#local-6989586621679500403"><span class="hs-identifier hs-var">mba</span></a></span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-86"></span><span>              </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MutableByteArray# d -&gt; Int# -&gt; Int# -&gt; State# d -&gt; State# d
forall d.
MutableByteArray# d -&gt; Int# -&gt; Int# -&gt; State# d -&gt; State# d
</span><a href="../../ghc-prim/src/GHC.Prim.html#writeInt8Array%23"><span class="hs-identifier hs-var">writeInt8Array#</span></a></span><span> </span><span class="annot"><span class="annottext">MutableByteArray# d
</span><a href="#local-6989586621679500403"><span class="hs-identifier hs-var">mba</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">0#</span></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">8#</span></span><span> </span><span class="annot"><span class="annottext">State# d
</span><a href="#local-6989586621679500404"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-87"></span><span>                </span><span id="local-6989586621679500402"><span class="annot"><span class="annottext">State# d
</span><a href="#local-6989586621679500402"><span class="hs-identifier hs-var">s2</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-88"></span><span>                  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679500401"><span class="annot"><span class="annottext">fillA :: Int# -&gt; Int# -&gt; Int# -&gt; State# d -&gt; State# d
</span><a href="#local-6989586621679500401"><span class="hs-identifier hs-var hs-var">fillA</span></a></span></span><span> </span><span id="local-6989586621679500400"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500400"><span class="hs-identifier hs-var">step</span></a></span></span><span> </span><span id="local-6989586621679500399"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500399"><span class="hs-identifier hs-var">val</span></a></span></span><span> </span><span id="local-6989586621679500398"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500398"><span class="hs-identifier hs-var">idx</span></a></span></span><span> </span><span id="local-6989586621679500397"><span class="annot"><span class="annottext">State# d
</span><a href="#local-6989586621679500397"><span class="hs-identifier hs-var">st</span></a></span></span><span>
</span><span id="line-89"></span><span>                        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#isTrue%23"><span class="hs-identifier hs-var">isTrue#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500398"><span class="hs-identifier hs-var">idx</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#%3C%23"><span class="hs-operator hs-var">&lt;#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">256#</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-90"></span><span>                                        </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MutableByteArray# d -&gt; Int# -&gt; Int# -&gt; State# d -&gt; State# d
forall d.
MutableByteArray# d -&gt; Int# -&gt; Int# -&gt; State# d -&gt; State# d
</span><a href="../../ghc-prim/src/GHC.Prim.html#writeInt8Array%23"><span class="hs-identifier hs-var">writeInt8Array#</span></a></span><span> </span><span class="annot"><span class="annottext">MutableByteArray# d
</span><a href="#local-6989586621679500403"><span class="hs-identifier hs-var">mba</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500398"><span class="hs-identifier hs-var">idx</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500399"><span class="hs-identifier hs-var">val</span></a></span><span> </span><span class="annot"><span class="annottext">State# d
</span><a href="#local-6989586621679500397"><span class="hs-identifier hs-var">st</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-91"></span><span>                                          </span><span id="local-6989586621679500396"><span class="annot"><span class="annottext">State# d
</span><a href="#local-6989586621679500396"><span class="hs-identifier hs-var">nx</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int# -&gt; State# d -&gt; State# d
</span><a href="#local-6989586621679500401"><span class="hs-identifier hs-var">fillA</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500400"><span class="hs-identifier hs-var">step</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500399"><span class="hs-identifier hs-var">val</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500398"><span class="hs-identifier hs-var">idx</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#%2B%23"><span class="hs-operator hs-var">+#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500400"><span class="hs-identifier hs-var">step</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">State# d
</span><a href="#local-6989586621679500396"><span class="hs-identifier hs-var">nx</span></a></span><span>
</span><span id="line-92"></span><span>                        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#isTrue%23"><span class="hs-identifier hs-var">isTrue#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500400"><span class="hs-identifier hs-var">step</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#%3C%23"><span class="hs-operator hs-var">&lt;#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">256#</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-93"></span><span>                                        </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int# -&gt; State# d -&gt; State# d
</span><a href="#local-6989586621679500401"><span class="hs-identifier hs-var">fillA</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">2#</span></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#%2A%23"><span class="hs-operator hs-var">*#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500400"><span class="hs-identifier hs-var">step</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500399"><span class="hs-identifier hs-var">val</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#%2B%23"><span class="hs-operator hs-var">+#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">1#</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679500400"><span class="hs-identifier hs-var">step</span></a></span><span>  </span><span class="annot"><span class="annottext">State# d
</span><a href="#local-6989586621679500397"><span class="hs-identifier hs-var">st</span></a></span><span>
</span><span id="line-94"></span><span>                        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">State# d
</span><a href="#local-6989586621679500397"><span class="hs-identifier hs-var">st</span></a></span><span>
</span><span id="line-95"></span><span>                  </span><span class="hs-keyword">in</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int# -&gt; State# d -&gt; State# d
</span><a href="#local-6989586621679500401"><span class="hs-identifier hs-var">fillA</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">2#</span></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">0#</span></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">1#</span></span><span> </span><span class="annot"><span class="annottext">State# d
</span><a href="#local-6989586621679500402"><span class="hs-identifier hs-var">s2</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-96"></span><span>                       </span><span id="local-6989586621679500395"><span class="annot"><span class="annottext">State# d
</span><a href="#local-6989586621679500395"><span class="hs-identifier hs-var">s3</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MutableByteArray# d -&gt; State# d -&gt; (# State# d, ByteArray# #)
forall d.
MutableByteArray# d -&gt; State# d -&gt; (# State# d, ByteArray# #)
</span><a href="../../ghc-prim/src/GHC.Prim.html#unsafeFreezeByteArray%23"><span class="hs-identifier hs-var">unsafeFreezeByteArray#</span></a></span><span> </span><span class="annot"><span class="annottext">MutableByteArray# d
</span><a href="#local-6989586621679500403"><span class="hs-identifier hs-var">mba</span></a></span><span> </span><span class="annot"><span class="annottext">State# d
</span><a href="#local-6989586621679500395"><span class="hs-identifier hs-var">s3</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-97"></span><span>                                </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# d
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679500394"><span class="annot"><span class="annottext">ByteArray#
</span><a href="#local-6989586621679500394"><span class="hs-identifier hs-var">ba</span></a></span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ByteArray#
</span><a href="#local-6989586621679500394"><span class="hs-identifier hs-var">ba</span></a></span><span>
</span><span id="line-98"></span><span>    </span><span class="hs-keyword">in</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">State# RealWorld -&gt; ByteArray#
forall {d}. State# d -&gt; ByteArray#
</span><a href="#local-6989586621679500406"><span class="hs-identifier hs-var">mkArr</span></a></span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="../../ghc-prim/src/GHC.Prim.html#realWorld%23"><span class="hs-identifier hs-var">realWorld#</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-99"></span><span>        </span><span id="local-6989586621679500393"><span class="annot"><span class="annottext">ByteArray#
</span><a href="#local-6989586621679500393"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ByteArray# -&gt; BA
</span><a href="GHC.Float.ConversionUtils.html#BA"><span class="hs-identifier hs-var">BA</span></a></span><span> </span><span class="annot"><span class="annottext">ByteArray#
</span><a href="#local-6989586621679500393"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-100"></span><span>
</span><span id="line-101"></span></pre></body></html>